package com.kepe.dragon.service;

import java.util.List;
import java.util.Map;
import java.util.Collection;

import org.coral.server.game.helper.ResourceType;
import org.coral.server.game.helper.log.NatureEnum;
import org.coral.server.game.module.player.domain.IPlayerService;
import org.coral.server.game.module.player.domain.Player;
import org.coral.server.game.module.player.domain.PlayerDomain;
import org.coral.server.game.module.player.manager.PlayerManager;
import org.coral.server.game.module.player.proto.*;
import org.coral.server.game.module.player.service.IPlayerService;
import org.coral.server.game.module.resource.IResourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * Player控制器
 */
@Service
public class PlayerService implements IPlayerService {
	
	private static final Logger log = LoggerFactory.getLogger(PlayerService.class);
	
	@Autowired private IPlayerService playerService;
	
	@Autowired private PlayerManager playerManager;
	
	/**
	 * 登陆
	 */
	public void onLogin(long playerId) {
		PlayerDomain domain = playerManager.getDomain(playerId);
		Collection<player> beans = domain.getBeans();
		//FSC todo somthing...
		//Codes for proto
		//playerService.sendMessage(playerId, ack);
	}
	
	/**
	 * 当玩家离线,移除掉道具模块数据
	 * @param playerId
	 */
	public void onLogout(long playerId) {
		playerManager.remove(playerId);
	}
	
	/**
	 * 更新信息
	 */
	public void responsePlayerInfo(PlayerDomain domain) {
		Collection<Player> beans = domain.getBeans();
		try {
			for (Player player : beans) {
				//resp.addArtifactlist(player.toProto());
			}
			//playerService.sendMessage(playerId, resp);
		} catch (Exception e) {
			e.printStackTrace();
			log.info("responsePlayerInfo error, playerId:{}", domain.getPlayerId());
			log.error("responsePlayerInfo error, e:", e);
		}
	}
	
	/////////////业务逻辑//////////////////
	
	
	/////////////接口方法////////////////////////
	
}